package NumberThree;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        ArrayList<Student> arrayList=new ArrayList<>();
        arrayList.add(new Student("马世超",21,"男"));
        arrayList.add(new Student("邵明芝",22,"女"));
        arrayList.add(new Student("张云璐",20,"男"));
        int max=arrayList.get(0).getAge();
        int index=0;
        for (int i = 1; i < arrayList.size(); i++) {
            if (arrayList.get(i).getAge()>max){
                max=arrayList.get(i).getAge();
                index=i;
            }
        }
        arrayList.get(index).setName("小猪佩奇");
        arrayList.forEach(System.out::println);
    }
}
